package com.fndsoft.police.xuancheng.ui.adapter;

import java.util.List;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.fndsoft.police.xuancheng.R;
import com.fndsoft.police.xuancheng.util.ViewUtil;

/**
 * 列表弹出框的适配器
 * 
 * @author carlos carlosk@163.com
 * @version 创建时间：2014年2月27日 下午5:43:44 类说明
 */

public class ListDialogAdapter extends COBaseAdapter<String> {
	private int seletedIndex;

	public ListDialogAdapter(List<String> dataList) {
		super(dataList);
		seletedIndex = -1;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = ViewUtil.buildView(R.layout.list_dialog_row);
		}
		TextView tvContent = (TextView) convertView
				.findViewById(R.id.tvContent);
		tvContent.setText(getData(position));
		View vIsSeleted = convertView.findViewById(R.id.vIsSeleted);
		if (seletedIndex == position) {
			ViewUtil.setViewsVisible(vIsSeleted);
		} else {
			ViewUtil.setViewsGone(vIsSeleted);
		}
		return convertView;
	}

	public void notifyDataSetChanged(int seletedIndex) {
		this.seletedIndex = seletedIndex;
		notifyDataSetChanged();
	}
}
